<?php

namespace model;

class UserCredentials {
	
	/**
	 * @var array $m_validUsernames
	 * @var array $m_validPasswords
	 * @var boolean $m_hasCorrectUsername
	 * @var boolean $m_hasCorrectPassword
	 * @var string $m_correctUsername
	 * @var string $m_correctPassword
	 * @return boolean
	 */

	private $m_validUsernames = array ("Admin", "Layla" ) ;
    private $m_validPasswords = array ("Password", "snygg");
    private $m_hasCorrectUsername = false;
    private $m_hasCorrectPassword = false;
    private $m_correctUsername = "";
    private $m_correctPassword = "";


	/**
	 * @param String Model
	 * @param String 
	 * @return boolean
	 */

	//validering
	//Här sätter vi rätt systemstatus och kontrollerar anändaruppgifterna
	public function checkUserCredentials($userUsername, $userPassword){

		for ($i = 0; $i < sizeof($this->m_validUsernames); $i++){
	
	          	
			if($userUsername == $this->m_validUsernames[$i]){
				
	                  $this->m_hasCorrectUsername = true;
	                  $this->m_correctUsername = $userUsername;
	
				if($userPassword == $this->m_validPasswords[$i]){
					
	                      $this->m_hasCorrectPassword = true;
	                      $this->m_correctPassword = $userPassword;
				}
	
	
			}
	
	
		}
	
	
		if($this->m_hasCorrectUsername == true && $this->m_hasCorrectPassword == true){
	           return true;
			
		} else {
	            return false;
	        }
	}
	
	// Detta görs för att undvika strängberoende
	/**
	 * @return boolean
	 */
    public function hasValidUsername(){
    	
        return $this->m_hasCorrectUsername;
    }

	/**
	 * @return boolean
	 */
    public function hasValidPassword(){
    	
        return $this->m_hasCorrectPassword;
    }
		
	/**
	 * @return string
	 */
    public function returnValidUsername(){
    	
        return $this->m_correctUsername;
    }
		
	/**
	 * @return string
	 */
    public function returnValidPassword(){
    	
        return $this->m_correctPassword;
    }

}




